﻿Imports BookOrderingSystem.BOSDataSetTableAdapters

Public Class Register
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser
        Dim continueUrl As String = RegisterUser.ContinueDestinationPageUrl
        If String.IsNullOrEmpty(continueUrl) Then
            continueUrl = "~/Account/Login.aspx"
        End If



        Dim tbUserName As TextBox = RegisterUserWizardStep.ContentTemplateContainer.FindControl("UserName")
        Dim userName As String = tbUserName.Text
        Dim tbEmail As TextBox = RegisterUserWizardStep.ContentTemplateContainer.FindControl("Email")
        Dim email As String = tbEmail.Text
        Dim tbPassword As TextBox = RegisterUserWizardStep.ContentTemplateContainer.FindControl("Password")
        Dim password As String = tbPassword.Text
        Dim tbphone As TextBox = RegisterUserWizardStep.ContentTemplateContainer.FindControl("phone")
        Dim phone As String = tbphone.Text
        Dim tbaddress As TextBox = RegisterUserWizardStep.ContentTemplateContainer.FindControl("address")
        Dim address As String = tbaddress.Text

        Dim adap As New UsersTableAdapter
        Dim cadap As New CustomersTableAdapter


        Dim userCount As Integer = adap.GetDataByUserName(userName).Count

        'For Each item As BookOrderingSystem.BOSDataSet.UsersRow In user
        '    item.
        'Next()

        If (userCount = 0) Then
            adap.Insert(userName, password, 1, 0, 0)
            cadap.Insert(email, phone, address)
            'Response.Redirect("~/Account/Login.aspx")
        End If



        Response.Redirect(continueUrl)
    End Sub
End Class